import { setStore, getStore, removeStore } from 'utils/store';
import website from '@/config/website';

const common = {
  state: {
    language: getStore({ name: 'language' }) || 'zh-cn',
    isCollapse: false,
    isFullScren: false,
    isMenu: true,
    isSearch: false,
    isRefresh: true,
    isLock: getStore({ name: 'isLock' }),
    themeName: getStore({ name: 'themeName' }) || 'default',
    lockPasswd: getStore({ name: 'lockPasswd' }) || '',
    website: website,
    setting: website.setting,
    optionsList: {
      // 险种
      ylfkfsOptions: [
        { label: '城镇职工基本医疗保险', value: '01' },
        { label: '城镇居民基本医疗保险', value: '02' }
      ],
      // 性别
      xbOptions: [
        { label: '男', value: '1' },
        { label: '女', value: '2' },
        { label: '未说明性别', value: '9' }
      ],
      // 国籍
      gjOptions: [
        { label: '中国', value: '156' }
      ],
      // 婚姻
      hyOptions: [
        { label: '已婚', value: '20' }
      ],
      // 名族
      mzOptions: [
        { label: '回族', value: '03' }
      ],
      // 职业
      zyOptions: [
        { label: '农民', value: '27' }
      ],
      // 关系
      gxOptions: [
        { label: '配偶', value: '1' }
      ],
      // 入院途径
      rytjOptions: [
        { label: '门诊', value: '2' }
      ],
      // 科别
      kbOptions: [
        { label: '心血管内科专业', value: 'A03.04' }
      ],
      // Rh
      rhOptions: [
        { label: '未查', value: '4' }
      ],
      // 病案质量
      bazlOptions: [
        { label: '甲', value: '1' }
      ],
      // 离院方式
      lyfsOptions: [
        { label: '其它', value: '9' }
      ],
      // 是否在住院计划
      sfzzyjhOptions: [
        { label: '无', value: '1' }
      ],
    }
  },
  mutations: {
    SET_LANGUAGE: (state, language) => {
      state.language = language;
      setStore({
        name: 'language',
        content: state.language,
      });
    },
    SET_COLLAPSE: state => {
      state.isCollapse = !state.isCollapse;
    },
    SET_IS_MENU: (state, menu) => {
      state.isMenu = menu;
    },
    SET_IS_REFRESH: (state, refresh) => {
      state.isRefresh = refresh;
    },
    SET_IS_SEARCH: (state, search) => {
      state.isSearch = search;
    },
    SET_FULLSCREN: state => {
      state.isFullScren = !state.isFullScren;
    },
    SET_LOCK: state => {
      state.isLock = true;
      setStore({
        name: 'isLock',
        content: state.isLock,
        type: 'session',
      });
    },
    SET_THEME_NAME: (state, themeName) => {
      state.themeName = themeName;
      setStore({
        name: 'themeName',
        content: state.themeName,
      });
    },
    SET_LOCK_PASSWD: (state, lockPasswd) => {
      state.lockPasswd = lockPasswd;
      setStore({
        name: 'lockPasswd',
        content: state.lockPasswd,
        type: 'session',
      });
    },
    CLEAR_LOCK: state => {
      state.isLock = false;
      state.lockPasswd = '';
      removeStore({
        name: 'lockPasswd',
        type: 'session',
      });
      removeStore({
        name: 'isLock',
        type: 'session',
      });
    },
  },
};
export default common;
